1 // DerelictCL - a Derelict based dynamic binding for OpenCL 2 // written in the D programming language 3 // 4 // Copyright: MeinMein 2013-2014. 5 // License: Boost License 1.0 6 // (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 // Authors: Gerbrand Kamphuis (meinmein.com), 9 // Marvin Meeng (meinmein.com). 10 module derelict.opencl.cl_egl; 11 12 import derelict.opencl.loader; 13 import derelict.opencl.types; 14 15 extern (System) 16 { 17 // OpenCL 1.0 18 alias nothrow cl_mem function(cl_context, CLeglDisplayKHR, CLeglImageKHR, cl_mem_flags, const(cl_egl_image_properties_khr), cl_int*) da_clCreateFromEGLImageKHR; 19 alias nothrow cl_mem function(cl_command_queue, cl_uint, const(cl_mem*), cl_uint, const(cl_event*), cl_event*) da_clEnqueueAcquireEGLObjectsKHR; 20 alias nothrow cl_int function(cl_command_queue, cl_uint, const(cl_mem*), cl_uint, const(cl_event*), cl_event*) da_clEnqueueReleaseEGLObjectsKHR; 21 alias nothrow cl_event function(cl_context, void*, void*, cl_int*) da_clCreateEventFromEGLSyncKHR; 22 } 23 24 __gshared 25 { 26 // OpenCL 1.0 27 da_clCreateFromEGLImageKHR clCreateFromEGLImageKHR; 28 da_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR; 29 da_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR; 30 da_clCreateEventFromEGLSyncKHR clCreateEventFromEGLSyncKHR; 31 } 32 33 package 34 { 35 void loadSymbols(void delegate(void**, string, bool doThrow) bindFunc) 36 { 37 38 } 39 40 CLVersion reload(void delegate(void**, string, bool doThrow) bindFunc, CLVersion clVer) 41 { 42 return clVer; 43 } 44 45 private __gshared bool _EXT_cl_khr_egl_image; 46 public bool EXT_cl_khr_egl_image() @property { return _EXT_cl_khr_egl_image; } 47 private void load_cl_khr_egl_image(CLVersion clVer, cl_platform_id platform) 48 { 49 try 50 { 51 loadExtensionFunction(cast(void**)&clCreateFromEGLImageKHR, "clCreateFromEGLImageKHR", clVer, platform); 52 loadExtensionFunction(cast(void**)&clEnqueueAcquireEGLObjectsKHR, "clEnqueueAcquireEGLObjectsKHR", clVer, platform); 53 loadExtensionFunction(cast(void**)&clEnqueueReleaseEGLObjectsKHR, "clEnqueueReleaseEGLObjectsKHR", clVer, platform); 54 55 _EXT_cl_khr_egl_image = clCreateFromEGLImageKHR !is null && 56 clEnqueueAcquireEGLObjectsKHR !is null && 57 clEnqueueReleaseEGLObjectsKHR !is null; 58 } 59 catch(Exception e) 60 { 61 _EXT_cl_khr_egl_image = false; 62 } 63 } 64 65 private __gshared bool _EXT_cl_khr_egl_event; 66 public bool EXT_cl_khr_egl_event() @property { return _EXT_cl_khr_egl_event; } 67 private void load_cl_khr_egl_event(CLVersion clVer, cl_platform_id platform) 68 { 69 try 70 { 71 loadExtensionFunction(cast(void**)&clCreateEventFromEGLSyncKHR, "clCreateEventFromEGLSyncKHR", clVer, platform); 72 73 _EXT_cl_khr_egl_event = clCreateEventFromEGLSyncKHR !is null; 74 } 75 catch(Exception e) 76 { 77 _EXT_cl_khr_egl_event = false; 78 } 79 } 80 81 void loadEXT(CLVersion clVer, cl_platform_id platform) 82 { 83 if(clVer >= CLVersion.CL10) 84 { 85 // OpenCL 1.0 86 load_cl_khr_egl_image(clVer, platform); 87 load_cl_khr_egl_event(clVer, platform); 88 } 89 } 90 }